<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>web.xml Visual Editor: Servlet Filters</title>
<link rel="stylesheet" href="ide.css" title="Oracle BLAFDoc" type="text/css"/>
</head>

<body>
<p><a id="dd_multiview_filters_filterMappingsNode" name="dd_multiview_filters_filterMappingsNode"></a></p>
<div id="NBCSH3800"><!-- infolevel="all" infotype="General" --><a id="sthref515" name="sthref515"></a>
<h1>web.xml Visual Editor: Servlet Filters</h1>
<a name="BEGIN" id="BEGIN"></a>
<p>Use the Servlet Filters section and the Filter Mappings section of the <code dir="ltr">web.xml</code> Visual Editor to add, remove, and view the deployment information of your web application's servlet filters. A filter is a piece of re-usable code that modifies requests to and responses from a servlet.</p>
<p>To deploy a filter, you must register it in the <code dir="ltr">web.xml</code> file. When you do this, you provide information needed by the server to deploy the filter. For example, you tell the server which types of requests should cause the filter to be deployed.</p>
<p>Before you can register a filter in the <code dir="ltr">web.xml</code> file, you must create it in the New File wizard or import it from your existing sources. You can use the Configure Filter Deployment panel of the New File wizard to register a filter. If you have not done so, or if you want to modify a registered filter's deployment information, use the Filters view of the <code dir="ltr">web.xml</code> Visual Editor.</p>
<p>In the Visual Editor, click <b>Filters</b> at the top of the editor to open the Filters view. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>
<p>First, click <b>Add Filter Element</b> to define the filter element with the following properties.</p>

<table summary="User interface elements and descriptions" dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<col width="24%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t9">Element</th>
<th align="left" valign="bottom" id="r1c2-t9">Description</th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t9" headers="r1c1-t9">
<p>Filter name</p>
</td>
<td align="left" headers="r2c1-t9 r1c2-t9">Specifies the filter's display name, such as <code dir="ltr">LoginFilter</code>. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t9" headers="r1c1-t9">
<p>Description</p>
</td>
<td align="left" headers="r3c1-t9 r1c2-t9">Specifies a description, such as <code dir="ltr">Performs pre- and post-login operations</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t9" headers="r1c1-t9">
<p>Filter Class</p>
</td>
<td align="left" headers="r4c1-t9 r1c2-t9">Specifies the filter's class, such as <code dir="ltr">MyLoginFlterClass</code>.</td>
</tr>
</tbody>
</table>
<br />
<!-- -->
<p>Next, click <b>Add</b> within the filter element and define its initialization parameters.</p>

<table summary="User interface elements and descriptions" dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<col width="24%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t10">Element</th>
<th align="left" valign="bottom" id="r1c2-t10">Description</th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t10" headers="r1c1-t10">
<p>Param Name</p>
</td>
<td align="left" headers="r2c1-t10 r1c2-t10">Specifies the parameter's display name, such as encoding. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t10" headers="r1c1-t10">
<p>Param Value</p>
</td>
<td align="left" headers="r3c1-t10 r1c2-t10">Specifies the parameter's value, such as <code dir="ltr">UTF-8</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t10" headers="r1c1-t10">
<p>Description</p>
</td>
<td align="left" headers="r4c1-t10 r1c2-t10">Specifies a description, such as <code dir="ltr">Acceptable encoding formats</code>.</td>
</tr>
</tbody>
</table>
<br />
<!-- -->
<p>Finally, click <b>Add</b> in the Filter Mappings section to map the filter to servlets or URL patterns to which the filter applies.</p>

<table summary="User interface elements and descriptions" dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<col width="24%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t11">Element</th>
<th align="left" valign="bottom" id="r1c2-t11">Description</th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t11" headers="r1c1-t11">
<p>Filter Name</p>
</td>
<td align="left" headers="r2c1-t11 r1c2-t11">Selects the filter to which the mapping applies, such as <code dir="ltr">LoginFilter</code>. 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1114">
<param name="text" value="<html><u>How?</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t11" headers="r1c1-t11">
<p>Apply To</p>
</td>
<td align="left" headers="r3c1-t11 r1c2-t11">Specifies the URL pattern or servlet to which the filter applies, such as <code dir="ltr">/Authenticate</code>.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t11" headers="r1c1-t11">
<p>Dispatcher types</p>
</td>
<td align="left" headers="r4c1-t11 r1c2-t11">Constrains how the filter will be applied to requests</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r5c1-t11" headers="r1c1-t11">
<p>&nbsp;&nbsp;&nbsp;&nbsp;Request</p>
</td>
<td align="left" headers="r5c1-t11 r1c2-t11">(Default) Only when the request come directly from the client.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r6c1-t11" headers="r1c1-t11">
<p>&nbsp;&nbsp;&nbsp;&nbsp;Forward</p>
</td>
<td align="left" headers="r6c1-t11 r1c2-t11">Only when the request has been forwarded to a component.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r7c1-t11" headers="r1c1-t11">
<p>&nbsp;&nbsp;&nbsp;&nbsp;Include</p>
</td>
<td align="left" headers="r7c1-t11 r1c2-t11">Only when the request is being processed by a component that has been included.</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r8c1-t11" headers="r1c1-t11">
<p>&nbsp;&nbsp;&nbsp;&nbsp;Error</p>
</td>
<td align="left" headers="r8c1-t11 r1c2-t11">Only when the request is being processed with the error page mechanism.</td>
</tr>
</tbody>
</table>
<br />
<!-- -->
<p>You can select one or more of the dispatcher types above.</p>
<p>Note that when you click <b>Remove</b> at the top of the Servlet Filters section, you remove the filter's deployment information from the <code dir="ltr">web.xml</code> file, but you do not remove the filter itself. To delete the filter, right-click it in the Projects window and choose Delete.</p>
<a id="NBCSH3814" name="NBCSH3814"></a>
<hr><p><b>Related Topics</b></p>
<p><i>Developing Applications with NetBeans IDE</i>, 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1103">
<param name="text" value="<html><u>&quot;Using Filters&quot;</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>
<p><i>Developing Applications with NetBeans IDE</i>, 
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer">
<param name="content" value="http://www.oracle.com/pls/topic/lookup?ctx=nb8200&id=NBDAG1111">
<param name="text" value="<html><u>&quot;Configuring a Web Application&quot;</u></html>">
<param name="textFontSize" value="medium">
<param name="textColor" value="blue">
</object>
</p>

<!-- -->
<!-- Start Footer -->


<table summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" width="86%"><a href="legal_notice.htm">
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0.</a>
</td>
</tr>
</table>
<!-- -->
</body>
</html>
